<template>
  <section>
    <div id="store-poster" class="store-top-three">
      <div class="shop-info">
        <div class="store_top_bg">
          <img src="../../assets/poster/store_top_bg.png" alt="" />
        </div>
        <div class="shop-meta">
          <div class="shop-logo">
            <img
              :src="shareObj.forwarder.forwarderShopLogoUrl || defaultImg"
              alt=""
            />
          </div>
          <div class="shop-desc">
            <span>{{
              shareObj.forwarder.forwarderMessage || '' | sliceHandle(19)
            }}</span>
            <span
              >{{ shareObj.forwarder.forwarderShopName || '' | sliceHandle(8) }}
            </span>
            <span>{{
              shareObj.forwarder.forwarderShopDesc || '' | sliceHandle(12)
            }}</span>
          </div>
        </div>
      </div>
      <template v-if="shareObj.mainPic">
        <div class="banner">
          <div class="goods-info">
            <div class="store_bottom_bg">
              <img src="../../assets/poster/store_bottom_bg.png" />
            </div>
            <img class="poster-img" :src="shareObj.mainPic" />
          </div>
        </div>
        <div class="qrcode-info_wrap">
          <div class="qrcode-info">
            <div class="link">
              <img class="poster-img" :src="qrcode" />
            </div>
            <div class="desc">
              <span>长按图片识别二维码进店立享优惠</span>
              <div class="desc-meta">
                <span v-for="(it, idx) in shareObj.tagList" :key="idx">
                  <i>
                    <img src="../../assets/poster/gouxuan.png" alt="" />
                  </i>
                  <em>{{ it }}</em>
                </span>
              </div>
            </div>
          </div>
        </div>
      </template>
      <template v-else>
        <div class="qrcode">
          <div class="link" style="width:244px;height:244px">
            <img class="poster-img" :src="qrcode" style="width:100%" />
          </div>
          <p>长按图片识别二维码，进店立享优惠</p>
          <div class="desc-meta">
            <span v-for="(it, idx) in shareObj.tagList" :key="idx">
              <i>
                <img src="../../assets/poster/gouxuan.png" alt="" />
              </i>
              <em>{{ it }}</em>
            </span>
          </div>
        </div>
      </template>
    </div>
  </section>
</template>

<script>
import defaultImg from '@/assets/poster/defaultImg.png';

export default {
  name: 'TopThreePoster',
  filters: {
    sliceHandle(value = '', length) {
      if (!value) {
        return '';
      }
      const arr = [...value];
      if (arr.length > length) {
        return arr.slice(0, length).join('') + '...';
      }
      return value;
    }
  },
  props: {
    shareObj: {
      type: Object,
      default: () => {}
    },
    qrcode: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      defaultImg
    };
  }
};
</script>

<style lang="scss" scoped>
.store-top-three {
  width: 300px;
  // height: 587px;
  box-sizing: border-box;
  padding-bottom: 20px;
  // width:375px;
  // height:654px;
  background: rgba(255, 255, 255, 1);
  font-family: PingFangSC-Regular, PingFang SC;
  .shop-info {
    box-sizing: border-box;
    position: relative;
    .shop-meta {
      display: flex;
      padding: 20px 20px 0 20px;
    }
    .store_top_bg {
      position: absolute;
      width: 100%;
      height: 40px;
      left: 0;
      bottom: -36px;
      img {
        width: 100%;
      }
    }
    .shop-logo {
      width: 48px;
      height: 48px;
      overflow: hidden;
      border-radius: 48px;
      box-sizing: border-box;
      img {
        width: 48px;
        height: 48px;
        border-radius: 48px;
        object-fit: cover;
      }
    }
    .shop-desc {
      display: flex;
      flex-direction: column;
      padding-left: 8px;
      font-size: 11px;
      color: rgba(102, 102, 102, 1);
      span {
        &:nth-child(1) {
          color: rgba(153, 153, 153, 1);
        }
        &:nth-child(2) {
          font-size: 14px;
          font-weight: 500;
          color: rgba(51, 51, 51, 1);
          padding-top: 4px;
          padding-bottom: 3px;
        }
      }
    }
  }
  .banner {
    width: 100%;
    position: relative;
    .goods-info {
      position: relative;
      width: 100%;
      padding-top: 24px;
      .store_bottom_bg {
        width: 100%;
        height: 40px;
        position: absolute;
        left: 0;
        bottom: -40px;
        img {
          width: 100%;
        }
      }
      img {
        width: 100%;
      }
    }
  }
  .qrcode-info_wrap {
    padding-top: 35px;
    justify-content: center;
    .qrcode-info {
      display: flex;
      justify-content: center;
      align-items: center;
      color: rgba(102, 102, 102, 1);
      font-size: 14px;
      .link {
        min-width: 64px;
        max-width: 64px;
        height: 64px;
        margin-left: 36px;

        img {
          width: 100%;
          height: 100%;
        }
      }
      .desc {
        color: rgba(102, 102, 102, 1);
        padding-left: 5px;
        display: flex;
        flex: 1;
        flex-direction: column;
        > span {
          max-width: 126px;
          padding-bottom: 8px;
          font-size: 11px;
        }
        .desc-meta {
          font-size: 10px;
          color: rgba(102, 102, 102, 1);
          display: flex;
          span {
            position: relative;
            padding-right: 6px;
            display: flex;
            i {
              width: 10px;
              height: 10px;
              margin-right: 5px;
              // margin-top:2px;
              &:last-child {
                margin: 0;
              }
              img {
                width: 100%;
              }
            }
            em {
              font-style: normal;
              font-size: 8px;
            }
          }
        }
      }
    }
  }
  .qrcode {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    padding .link {
      width: 244px;
      height: 244px;
      padding-bottom: 20px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    p {
      color: rgba(153, 153, 153, 1);
      font-size: 11px;
    }
    .desc-meta {
      font-size: 10px;
      color: rgba(102, 102, 102, 1);
      padding-top: 40px;
      display: flex;
      justify-content: center;
      span {
        position: relative;
        padding-right: 26px;
        display: flex;
        &:last-child {
          padding-right: 0;
        }
        i {
          width: 10px;
          height: 10px;
          margin-right: 5px;
          &:last-child {
            margin: 0;
          }
          img {
            width: 100%;
          }
        }
        em {
          font-style: normal;
          margin-top: -2px;
        }
      }
    }
  }
}
</style>
